package com.mall.shopping.dto;

import com.mall.commons.tool.utils.ObjectIsEmptyUtils;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 *
 */
public class ProductDetailDto implements Serializable {

    private static final long serialVersionUID = -597050593951733519L;
    private Long productId;

    private BigDecimal salePrice;

    private String productName;

    private String subTitle;

    private Long limitNum;

    private String productImageBig;

    private String detail;

    private List<String> productImageSmall;

    //private String image;

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public BigDecimal getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(BigDecimal salePrice) {
        this.salePrice = salePrice;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getSubTitle() {
        return subTitle;
    }

    public void setSubTitle(String subTitle) {
        this.subTitle = subTitle;
    }

    public Long getLimitNum() {
        return limitNum;
    }

    public void setLimitNum(Long limitNum) {
        this.limitNum = limitNum;
    }

    public String getProductImageBig() {
        return productImageBig;
    }

    public void setProductImageBig(String image) {
        if (!ObjectIsEmptyUtils.stringIsEmpty(image)) {
            if (image.contains(",")) {
                this.productImageBig = image.split(",")[0];
            } else {
                this.productImageBig = image;
            }
        }
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public List<String> getProductImageSmall() {
        return productImageSmall;
    }

    public void setProductImageSmall(String image) {
        if (!ObjectIsEmptyUtils.stringIsEmpty(image)) {
            if (image.contains(",")) {
                this.productImageSmall = Arrays.asList(image.split(","));
            } else {
                this.productImageSmall = Collections.singletonList(image);
            }
        }
//        if (image != null && !"".equals(image)) {
//            if (image.contains(",")) {
//                String[] arr = image.split(",");
//                this.productImageSmall = Arrays.asList(arr);
//            } else {
//                this.productImageSmall = Collections.singletonList(image);
//            }
//        }
    }
}
